package xyz.quanguanjia.masterboy;

import android.graphics.Rect;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

public class MBDUploadGroupItemDecoration extends RecyclerView.ItemDecoration {

    private UploadGroupItemClickListener itemClickListener;


    public MBDUploadGroupItemDecoration(UploadGroupItemClickListener listener) {
        this.itemClickListener = listener;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        super.getItemOffsets(outRect, view, parent, state);
        // 设置单元格的点击事件
        view.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // 处理点击事件
                if (itemClickListener != null) {
                    int position = parent.getChildAdapterPosition(view);
                    itemClickListener.onItemClick(position);
                }
            }
        });
    }

    // 自定义点击事件接口
    public interface UploadGroupItemClickListener {
        void onItemClick(int position);
    }

}
